THINK C 5.0.1 lets you debug programs on a Macintosh with a MC68040 and
corrects some bugs in THINK C 5.0.
This document has five sections:
• UPDATING THINK C tells you how to run “THINK C => 5.0.1” to
update your copy of THINK C.
• WHAT THIS UPDATE FIXES lists the most important bugs that
this update fixes.
• LAST MINUTE CHANGES lists some last minute changes and
corrections to the THINK C User Manual and Standard Libraries
Reference. This section contains much of the information in the
READ ME file on your THINK C 5.0 disk, in addition to some more
recent information.
• TECH TIPS answers some common questions that people ask
our Technical Support staff. When you have a problem with
THINK C, use this section along with Appendix B,
“Troubleshooting,” to try to find a solution. And when you
port a program from THINK C 4.0 to THINK C 5.0, use this
section along with Appendix A, “What’s New,” for some helpful
hints.
•••••••••
IMPORTANT
•••••••••
Some copies of the Object-Oriented Programming Manual have
a misprint: page 313 is a duplicate of page 321. To get a copy of
the correct 313, you need to use the THINK Class Library 1.1.1
update.
UPDATING THINK C
=================
This update transforms your existing THINK C 5.0 application to THINK C
5.0.1. You will run the patch program “THINK C => 5.0.1” and then replace
your debugger.
1. Make sure that you have your original THINK C application.
You won't need it for this update, but you should make
sure that you have a backup in case the update fails. Do not
patch your original master disk.
2. Double-click on the patch program "THINK C => 5.0.1" to
launch it. Click on the Update THINK C button to continue.
3. Find your existing copy of THINK C in your THINK C Folder.
Select it and click on the Patch button.
4. If the patch was successful, you'll get a confirmation.
5. Replace your THINK C 5.0 Debugger with the THINK C 5.0
Debugger included with the upgrade.
6. Recompile all the files in your projects to make sure they
take advantage of the changes. To recompile a project, open
it in THINK C, choose Remove Objects from the Project menu,
and choose Bring Up To Date from the Project menu.
WHAT THIS UPDATE FIXES
=======================
THINK C 5.0.1 is a minor update to THINK C 5.0 that lets you debug programs on a Macintosh with the MC68040 and fixes some bugs. This section describes the most
significant bugs that THINK C 5.0.1 fixes. It contains these parts:
• “The Environment” describes what’s fixed in the THINK C
environment.
• “Optimizations” describes what’s fixed in THINK C’s global optimizer and
other optimizations.
• “Object-Oriented Programming Extensions” describes what’s fixed in
THINK C’s object-oriented programming extensions.
• “Compiler and Linker” describes what else is fixed in THINK C‘s compiler
and linker.
The Environment
---------------
• When you’re running System 7.0 in 32-bit addressing mode, these features
now work correctly:
√ The “Grep” option in the Find… dialog.
√ Using the Browser to look up a method or class definition.
• The Get Info… dialog doesn’t truncate the last character of the JUMP table
size.
Optimizations
-------------
• The “Suppress redundant loads” option is more careful when choosing to
suppress a load.
• The “CSE elimination” option is more careful when deciding
whether to eliminate common sub-expressions in switch expressions.
• The “Induction variable elimination” option is more careful when
deciding whether an expresion is an induction variable.
• The “CSE elimination” and “Register coloring” options are more careful
when optimizing statements with the operators && or ||.
Object-Oriented Programming Extensions
-------------------------------------
• THINK C now flags as an error a static member function that references
a non-static member of a class without an object pointer.
• Calling a virtual static method works correctly.
Compiler and Linker
------------------
• There is now a limit of 256 segments per project. THINK C 5.0 had a limit
of 128 segments per project.
• You do not get the incorrect error message “internal error: Bad ZREF,” if
the linker encounters an error while building your program.
• If you use typedef to define a type as void and declare something with
that type, you do not get the error message “illegal use of void”.
• If there are several #define statements before a precompiled header,
THINK C does not generate an internal compiler error.
• THINK C now correctly stores the size of array types declared in
precompiled headers.
• If a macro and a type have the same name, and you use the name to
declare a variable, THINK C does not give you the incorrect error message
“invalid declaration.”
• A multi-segment code resource, driver, or desk accessory built with
THINK C works correctly if it is unlocked and moves in memory.
• When assigning one struct to another, the code THINK C generates now
works correctly if the source struct is cached in an MC68040 data
register.
• The FNEG.X instruction generates correct code when you use it with a
single floating-point register argument. Previously, for example,
“FNEG.X FP0” generated code for “FABS.X FP0”.
LAST MINUTE CHANGES
====================
This section lists some last minute changes and corrections to the THINK C
User Manual and Standard Libraries Reference. It contains much of the
information in the READ ME file on your THINK C 5.0 disk, in addition to some
more recent information.
Installing THINK C 5.0
--------------------
• On page 20, step 4 should refer you to Figure 2-2, not 2-1.
• On page 21, the folder is shown in Figure 2-3, not 2-1.
Tutorial: MiniEdit
----------------
• The first paragraph on page 49 tells you to click the wrong button. You
should click on the Done button, not the Cancel button.
• On pages 55 and 56, the Set Project Type… dialog in Figures 4-14 and
4-15 probably doesn’t match yours. The default value for the SIZE Flags
field is 0000, and not 0800. The project works correctly with either
value.
• On page 57, the first sentence of the section “Using a Resource File” is
incorrect. You didn’t copy the MiniEdit Folder from disk THINK C 4.
Instead you installed it with the self-extracting archive “THINK C 5.0
Demos.sea,” according to the instructions in Chapter 2, “Installing
THINK C 5.0.”
The Compiler
-------------
• The THINK C compiler and optimizer use MultiFinder memory. If you get an
“Out of Memory“ error, quit your other running applications to increase
the amount of MultiFinder memory available.
• The optimizer can take a long time to optimize extremely large and
complex functions (typically, more than 10 pages of dense code).
The Assembler
--------------
• The note on page 270 needs some explanation. When you write a
function with in-line assembly and you declare that function pascal, you
need to return the function’s value in a return statement outside the
assembly block. Don’t put the return value into D0 yourself. For example,
use this:
pascal int foo (void)
{
asm {
. . .
}
return 1;
}
instead of this:
pascal int foo (void)
{
asm {
. . .
move.w #1, D0
}
}
Also note that you cannot return a value from an assembly block.
In an assembly block, you can use a return statement only if it does not
return a value. For example, this code fragment causes an error:
pascal int foo (void)
{
asm {
. . .
return 1 // NO! Cannot return a value from
} // within an asm block
}
• In THINK C 5.0, you need to write multi-line assembly language macros
differently than with earlier versions of THINK C. For example, this
multi-line macro causes an error in THINK C 5.0:
#define LongMult(r, s1, s2) \
asm { \
move.w s1, d0 \
muls s2, d0 \
move.l d0, r \
}
void foo(void)
{
int a, b;
long d;
LongMult(d, a, b) // Syntax error
. . .
}
Multi-line assembler macros cause errors because the THINK C 5.0
preprocessor expands the macro as one long line, like this:
asm { move.w s1, d0 muls s2, do move.l d0,r }
The inline assembler doesn’t recognize the expansion as valid assembly
language. You can define the macro like this:
#define LongMult(r, s1, s2) \
asm { move.w s1, d0 } \
asm { muls s2, d0 } \
asm { move.l d0, r }
Or you can define LongMult as just the assembly language statements,
without enclosing them in asm { . . . }, like this:
#define LongMult(r, s1, s2) \
move.w s1, d0 \
muls s2, d0 \
move.l d0, r
And then use the macro like this:
void foo(void)
{
int a, b;
long d;
asm {
LongMult(d, a, b)
}
. . .
}
• On page 267, there’s an error in the section “C function entry.” It
incorrectly states how THINK C handles a char-sized argument. The last
two paragraphs in that section should read:
All arguments occupy an even number of bytes on the stack.
If there is no prototype for a char-sized argument, it is placed
in the low byte of an int, which may be 2 or 4 bytes, depending
on your option settings.
If there is a prototype for a char-sized argument, it is placed
in the high byte of a short.
The Debugger
------------
• To stop the debugger from saving the current session, hold down the
Option key as you exit the debugger.
• To make the debugger display the source and data window in their
default positions, hold down the Shift key as you enter the debugger.
• To stop the debugger from restoring saved breakpoints and data
expressions hold down the Option key as you enter the debugger.
Standard Libraries Reference
--------------------------
• On pages 208 and 209, the return value for the “isxxxx” family of
functions (isalnum(), isalpha(), etc.) is wrong. The second sentence in
the second paragraph should read:
It returns non-zero if c is a member of the category, and
0 (zero) value if c isn’t.
And the table in the section “Returns” should read:
If c is… The function returns…
in the category non-zero
not in the category 0 (zero)
TECH TIPS
=========
THINK C has many new features and enhancements that help you improve
your code. Two changes in THINK C 5.0 affect existing programs and
programs that you write in the future. The first change is that THINK C 5.0
conforms the ANSI standard. The second change is that THINK C now uses
the same Macintosh Toolbox interface files that Apple provides, and these
files contain more type-checking information than the built-in interfaces
in earlier versions of THINK C.
Though these changes in the THINK C development environment may mean
some changes to your existing programs, these programs will be easier to
maintain and more bug-free.
MacHeaders uses Apple’s interfaces
--------------------------------
The MacHeaders file that comes with THINK C 5.0 contains the interfaces for
the most common Macintosh Toolbox routines. This MacHeaders file is
precompiled with the "Check pointer types" option off, so all pointer types
in function prototypes are treated as generic pointers of type void *. If you
want stricter type checking for Macintosh Toolbox routines, follow the
instructions in Mac #includes.c to turn the stricter checking on.
Using stricter type-checking means that you need to cast parameters to
all Macintosh Toolbox routines, even the common ones like HLock() and
HUnlock(). The additional work pays off when THINK C catches an attempt to
pass a variable of the wrong type to a Toolbox routine.
Prototype Helper helps convert programs
-------------------------------------
The THINK C 5.0 package includes a tool called Prototype Helper to help you
convert your programs to the new ANSI standard. Prototype Helper creates
extra header files that contain the prototypes for all the functions in your
program files. Prototype Helper also converts old-style function definitions
to new-style ANSI function definitions. Many programmers report that
Prototype Helper helped them discover subtle problems that have hidden in
programs for months.
Prototype Helper uses a heuristic to convert your files, and may not always
do what you expect. Since it alters your files in place, be sure to keep a
backup of your files until you’re confident your converted files work
properly.
Function pointer types are more strictly enforced
---------------------------------------------
THINK C 5.0 is much stricter about function pointer types than earlier
versions of THINK C. In older versions, THINK C ignored the parameters to a
function pointer. For example, THINK C 4.0 treated both of these types
identically:
typedef int (*SomeProcPtr)();
typedef int (*OtherProcPtr)(char);
THINK C 5.0 treats these two declarations as distinct types. It distinguishes
function pointer types by parameters as well as return value. THINK C 5.0
also allows the use of the keyword pascal as part of the function pointer
type.
This change affects programs that use the type ProcPtr as a generic pointer.
For example, in THINK C 4.0, you could write this:
ProcPtr fp;
(*fp)(1, 2L, 3);
In THINK C 5.0, this function pointer needs an explicit type. You can cast it